<template>
    <div class="dialoglistDiv">
        <div class="table_box"><div class="table_" id="tb">
            <ul class="head">
                <li class="liflex">企业名称</li>
                <li class="mw200">查看时间</li>
            </ul>
            <div class="body">
                <ul v-for="x in obj.ary" :key="x">
                    <li class="liaction liflex">
                        <u @click.prevent="edit(x)">{{x.companyname}}</u>
                    </li>
                    <li class="mw200">{{x.intime}}</li>
                </ul>
            </div>
        </div>
        </div><Pager :value="obj.req" :init="init" />
        <el-dialog v-model="obj.drawer.design" :title="obj.drawer.designTitle" width="1380px" :close-on-click-modal="false" :destroy-on-close="true">
            <Compamy :detail="obj.drawer.detail"></Compamy>
        </el-dialog>
    </div>
</template>

<script setup>
    import { reactive, getCurrentInstance, ref, inject, provide, computed } from 'vue'
    import Pager from '@/components/pager.vue'
    import Compamy from "./company_detail.vue"
    import { ElMessageBox } from 'element-plus'
    let { proxy } = getCurrentInstance()

    let obj = reactive({
        ary: [],
        req: {
            currentpage: 1,
            pagesize: 10,
            count: 0,
            banking_id: inject("id").value || 0,
        },
        drawer: {
            design: false,
            designTitle: "",
            detail:"",
        },
    });
    let init = () => {
        proxy.$ajax({
            url: 'banking/company',
            data: obj.req,
            bfLoading: true
        }).then(d => {
            // console.log(d)
            if(d.success){
                obj.ary = d.msg.list
                obj.req.count = d.msg.count
            }
        }).catch(() => { })
    }
    let edit = x => {
        // console.log(x)
        proxy.$ajax({
            url: '/banking/company_get ',
            data: { read_id: x.read_id },
            bfLoading: true
        }).then(d => {
            console.log(d)
            if(d.success && d.msg.state){
                obj.drawer.design = true
                obj.drawer.designTitle = "查看企业资料"
                obj.drawer.detail = d.msg.msg.msg;
                return
            }
            if(d.msg.msg==='无查看权限，请联系运营管理员'){
                ElMessageBox.confirm('无查看权限，确认要申请吗？', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    distinguishCancelAndClose: true,
                }).then(() => {
                    proxy.$ajax({
                        url: '/docking/apply',
                        data: {},
                        bfLoading: true
                    }).then(d1 => {
                        // console.log(d1)
                        if(d1.success){
                            proxy.elMessageMixin("申请成功", 'success')
                        }else{
                            proxy.elMessageMixin(d1.err, 'error')
                        }
                    }).catch(() => { })
                }).catch(() => {})
            }
        }).catch((err) => {})
    }

</script>

<style scoped>
    ::-webkit-scrollbar { width:10px; background-color: #FFFFFF; }
    .listDiv { top:70px; }
    #tb ul li.li2 { width: 70px; }
    #tb ul li.li3 { width: 70px; }
</style>